<extend name="Public/base"/>
<block name="body">
      <div class="row">
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf">
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl">分组编辑</div>
                                <div class="widget-function am-fr">
                                    <a href="javascript:;" class="am-icon-cog"></a>
                                </div>
                            </div>
                            <div class="widget-body am-fr">
                                <form class="am-form tpl-form-line-form" action="{:U()}" method="post" onsubmit="return chkform(this);">
                                    <div class="am-form-group">
                                        <label for="user-name" class="am-u-sm-3 am-form-label">分组名称<span class="tpl-form-line-small-title"></span></label>
                                        <div class="am-u-sm-9">
                                            <input type="text" class="tpl-form-input"   name="group_name" value="{$group.group_name}">
                                            <input type="hidden" name="id" value="{$group.id}">
                                            <small>分组名称为必填</small>
                                        </div>
                                    </div>                    
                                    <div class="am-form-group">
                                        <label for="user-phone" class="am-u-sm-3 am-form-label">是否隐藏<span class="tpl-form-line-small-title"></span></label>
                                        <div class="am-u-sm-9">
                                            <select data-am-selected="{searchBox: 1}" style="display: none;" name="disable" id="disable">
                                              <option value="0"><font color="green">否</font></option>
                                              <option value="1"><font color="red">是</font></option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="am-form-group">
                                        <label for="user-phone" class="am-u-sm-3 am-form-label">权限分配<span class="tpl-form-line-small-title"></span></label>
                                            <table border="1px solid black" width="" >
                                            <volist name='menus' id='menus'>
                                                <tr >
                                                    <td style="text-align:left;margin-left: 20px;"><input name="rules[]" type="checkbox" value="{$menus['id']}" />{$menus.menu_name}&nbsp;&nbsp;&nbsp;</td>
                                                    <td style="text-align:left;">
                                                        <volist name="menus.child" id="childs">
                                                            <input name="rules[]" type="checkbox" value="{$childs['id']}" />{$childs.menu_name}&nbsp;&nbsp;
                                                        </volist>
                                                    </td>
                                                </tr>
                                            </volist>
                                            </table>
                                    </div>
                                  <div class="am-form-group">
                                        <div class="am-u-sm-9 am-u-sm-push-3">
                                            <button type="submit" class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <script>
                    $("#disable option[value='{$group.disable}']").attr("selected", "selected");
                    var rules = eval('('+'{$rules}'+')');
                    function contains(arr, obj) {
                        var i = arr.length;
                        while (i--) {
                            if (arr[i] == obj) {
                                return true;
                            }
                        }
                        return false;
                    }
                    $("input[name='rules[]']").each(function(e){
                        if(contains(rules,$(this).val()) == true){
                            $(this).attr('checked',true);
                        }
                    });
                </script>
</block>